// src/store/authStore.ts
import { defineStore } from "pinia";

interface AuthState {
	token: string;
	userInfo: {
		id?: string;
		name?: string;
	};
}

export const useAuthStore = defineStore("auth", {
	state: (): AuthState => ({
		token: "",
		userInfo: {},
	}),

	actions: {
		setToken(token: string) {
			this.token = token;
		},

		setUserInfo(userInfo: AuthState["userInfo"]) {
			this.userInfo = userInfo;
		},
	},

	persist: {
		key: "AuthStore",
	},
});
